<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Admin extends MY_Controller {

	public function __construct()
	{
        parent::__construct();
       
       
    }
	public function index()
	{
	   //$this->load->view("v-admin/v-product-curd");
       //$var=$this->m_admin->login('admin','123456');
       //var_dump ($var);

	  // $this->load->view("v-admin/v-product-curd");

	}
    /**
     * Ham dang nhap admin
     */
    public function login(){
        $uri="admin/product";
        //neu dang nhap thi chuyen trang
        if($this->m_admin->logged_in() == true){
            redirect($uri);
        }
        $btn_click=$this->input->post('btn-login');
                
        if($btn_click != NULL)
        {
            $txt_user=$this->input->post('txt_user');
            $txt_pass=$this->input->post('txt_pass');
            
            if($txt_pass != NULL and $txt_user != NULL)
            {
                //echo $user.$pass;
                if($this->m_admin->login($txt_user, $txt_pass))
                    redirect($uri);
            }
             else{  

            $this->data['error']="vui long nhap day du thong tin";
        }
       
            
        }
      
       $this->data['test1']=$this->m_admin->cry("123456");
        $this->load->view("v-admin/v-login", $this->data);
    }  
	  public function product(){
		//load model
		//$this->load->model('M_Admin');
       	// đã đăng nhập rồi chưa trả về true fales
		// $kt=this->load->model("hàm kiểm tra đăng nhập")
		//	if($kt!=true) {đá về login}	
		
	 	// get data 
		$this->data=array("data_menu_product"=>$this->m_admin->get_menu_product(),
							"data_unit"=>$this->m_admin->get_unit(),
							"data_product"=>$this->m_admin->get_product(),
							);
        
		//load view
		$this->data['subview']="v-admin/v-product-curd";	
        $this->load->view("v-admin/v-admin-layout",$this->data);
		
    }    //end product
	 public function banner(){		
		//load views
		$this->data['subview']="v-admin/v-banner";	
        $this->load->view("v-admin/v-admin-layout",$this->data);		
    }    //end banner
	 public function list_pro(){		
		//load list pro
		$this->data['subview']="v-admin/v_list_pro";	
        $this->load->view("v-admin/v-admin-layout",$this->data);		
    }    //end list pro
    public function logout(){
        $this->m_admin->logout();
        redirect("admin/login");
    }
    public function config(){
        $webname=$this->input->post("btn_TenWebsite");
        $Tagline=$this->input->post("Tagline");
        $FbLink=$this->input->post("btn_Facebooklink");
        $Googlepluslink=$this->input->post("btn_Googlepluslink");
        $Twitterlink=$this->input->post("btn_Twitterlink");
        if($webname!=NULL ){
             $this->data['webname']="thêm webname";
        }
        if(isset($Tagline) and $webname!=NULL ){
             $this->data['Tagline']="thêm Tagline";
        }
        if(isset($FbLink) and $webname!=NULL ){
             $this->data['FbLink']="thêm FbLink";
        }
        if(isset($Googlepluslink) and $webname!=NULL ){
             $this->data['Googlepluslink']="thêm Googlepluslink";
        }
        if(isset($Twitterlink) and $webname!=NULL ){
                     $this->data['Twitterlink']="thêm Twitterlink";
                }
        
        $this->data['subview']="v-admin/v-config";
        $this->load->view('v-admin/v-admin-layout',$this->data);
    }
    public function testpost(){
        if($_POST['txt_name']);
        $kq="thành công";
        return $kq;
    }
}
?>